package com.example.park2301.news

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.lifecycle.lifecycleScope
import androidx.paging.cachedIn
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView.LayoutManager
import com.alibaba.android.arouter.facade.annotation.Route
import com.example.lib_base.mvvm.BaseActivity
import com.example.park2301.R
import com.example.park2301.databinding.ActivityNewBinding
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.launch

@AndroidEntryPoint
@Route(path = "/app/NewActivity")
class NewActivity : BaseActivity<ActivityNewBinding,NewsViewModel>() {
    val newsAdapter by lazy { NewsAdapter() }
    override fun initView() {
        binding.newsRv.apply {
            adapter=newsAdapter
            layoutManager=LinearLayoutManager(this@NewActivity)
        }
        lifecycleScope.launch {
            vm.getNews().collect(){
                newsAdapter.submitData(it)
            }
        }
    }

    override fun initData() {

    }

}